<template>
  <div>
    <h2>欢迎登录学生管理系统</h2>
    <hr>
<!--    用户名:<input type="text" v-model="username"><br>-->
<!--    密码:<input type="password" v-model="password"><br>-->
<!--    <button @click="loginEms" type="primary">登录</button>-->


    <div class="a">
      <el-input v-model="username" placeholder="请输入用户名" size="mini"></el-input><br><br>
      <el-input placeholder="请输入密码" v-model="password" show-password size="mini" ></el-input>
    </div>
    <br>
    <el-button  @click="loginEms" type="success" round  size="small">登录</el-button>

  </div>
</template>

<script>
export default {
  name: "Login",
  data(){
    return{
      username:"",
      password:"",
      //input:"",
    }
  },
  methods:{
    loginEms(){
      this.$axios({
        url:"http://localhost:8989/ems/loginEms",
        method:"POST",
        data:{
          username: this.username,
          password: this.password,
        }
      }).then(res => {
        console.log(res)
        if(res.data==1){
          alert("您好,您已经登录成功")
          this.$router.push("/ems")
        }else {
          alert("您好,登录失败请重新登录")
        }
      }).catch(error =>{
        console.log(error)
      })
    }
  }
}
</script>

<style scoped>
 .a{
   width:10%;
   align:"center"
 }
</style>
